package com.sz.sboot.entity;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;


@Component
@PropertySource(value = {"classpath:tuser.properties"}) //加载配置文件
@ConfigurationProperties(prefix = "tuser") //将配置文件中的tuser和本类进行绑定
@Table(name = "t_user")
@ApiModel("用户实体类")
public class TUser implements Serializable {
    @Id
    @KeySql(useGeneratedKeys = true)
    //主键生成机制,添加sql语句时候,可以把刚添加的主键ID复制给对象
    @ApiModelProperty("用户id")
    private Integer uid;
    //@Value("${tuser.uname}") 单独绑定一个值
    @ApiModelProperty("用户名")
    private String uname;
    @ApiModelProperty("用户密码")
    private String upwd;
    @ApiModelProperty("角色id")
    private Integer rid;

    public TUser() {
    }

    public TUser(String uname, Integer rid) {
        this.uname = uname;
        this.rid = rid;
    }

    public TUser(Integer uid, String uname, String upwd, Integer rid) {
        this.uid = uid;
        this.uname = uname;
        this.upwd = upwd;
        this.rid = rid;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getUpwd() {
        return upwd;
    }

    public void setUpwd(String upwd) {
        this.upwd = upwd;
    }

    public Integer getRid() {
        return rid;
    }

    public void setRid(Integer rid) {
        this.rid = rid;
    }

    @Override
    public String toString() {
        return "TUser{" +
                "uid=" + uid +
                ", uname='" + uname + '\'' +
                ", upwd='" + upwd + '\'' +
                ", rid=" + rid +
                '}';
    }
}
